package com.example.activity_service.service.impl;

import com.example.activity_service.dao.Jpdao;
import com.example.activity_service.service.JPQueryService;
import com.example.activity_service.vo.Admin;
import com.example.activity_service.vo.Dui;
import com.example.activity_service.vo.Red;
import com.example.activity_service.vo.Red_goods;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Repository
public class JPServicelmpl implements JPQueryService {
    @Autowired
    Jpdao userdao;

    @Override
    public List<Admin> admin(int ye) {
        return userdao.admin(ye);
    }

    @Override
    public int totalRecord() {
        return userdao.totalRecord ();
    }

    @Override
    public void addhongbao(String id, String qian) {
        Red red=new Red();

        red.setRedenvelopes("红包雨优惠卷");
        red.setInstructions("任意商品");
        red.setSharingoffers(0);
        red.setPreferentialway(0);
        red.setParvalue(Double.parseDouble(qian));
        red.setScopeofapplication(0);
        red.setReceivingrules("已领取");
        red.setUsers(Integer.parseInt(id));//cha出来的
        red.setStatus(1);

        userdao.addhongbao(red);
    }

    @Override
    public void adadmi(String name, String dizi,String tu)
    {

        System.out.println(dizi.substring(12,dizi.length()));
        userdao.adadmi(name,dizi.substring(12,dizi.length()),"images/"+tu.substring(12,tu.length()) );
    }

    @Override
    public void adxiu(String id, String zt) {
        userdao.adxiu(id,zt);
    }

    @Override
    public int schuo(String id) {
     return    userdao.schuo(id);
    }

    @Override
    public List<Red_goods> duica(int fe) {
        return userdao.duica(fe);
    }

    @Override
    public int catotalRecord() {
        return userdao.toca();
    }

    @Override
    public void adddui(Dui dui) {
        userdao.adddui(dui);
    }

    @Override
    public void scdui(String id) {
        userdao.scdui(id);
    }

    @Override
    public void xiudui(Dui dui) {
        userdao.xiudui(dui);
    }
}
